<template>
  <div class="app-container">

    <el-row :gutter="20">
      <el-col :span="4" :xs="24">
        <el-row :gutter="10" class="mb8" ref="hMain">
          <el-col :span="1.5">
            <el-button type="primary" plain icon="el-icon-plus" size="small" @click="treeHandleAdd">新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="success" plain icon="el-icon-edit" size="small" @click="treeHandleUpdate">修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" plain icon="el-icon-delete" size="small" @click="treeHandleDelete">删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="warning" plain icon="el-icon-warning" size="small"
                       v-hasPermi="['archive:category:SyncSubSysTable']"
                       @click="treeHandleSync">同步</el-button>
          </el-col>
        </el-row>

        <div class="head-container" :style="{ height: treeHeight + 'px' }" style="overflow: auto">
          <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false" ref="tree" node-key="id"
            default-expand-all highlight-current @node-click="handleNodeClick" :filter-node-method="filterNode"
            :default-expanded-keys="expandedkeys" :current-node-key="currentNodekey" :style="isSize" />
        </div>
      </el-col>
      <el-col :span="20" :xs="24">
        <el-tabs v-if="!isfondsCode" type="border-card" v-model="activeName" :style="{ height: tableHeight + 'px' }">
          <el-tab-pane label="无数据" name="first">
            <el-empty description=" " style="margin-top:10%;"></el-empty>
          </el-tab-pane>
        </el-tabs>
        <el-tabs v-else v-model="activeName" type="border-card" @tab-click="handleTabClick">
          <el-tab-pane label="门类信息" name="first">
            <ul class="first" ref="firstForm" :model="firstForm" :style="isSize">
              <li><label>门类名称：</label>{{ firstForm.name }}</li>
              <li><label>门类代码：</label>{{ firstForm.code }}</li>
              <!--<li><label>全&#160;宗&#160;号：</label>北京市某某局</li>-->
              <li><label>档案库类型：</label>{{ firstForm.storeType }}</li>
              <li><label>整理方式：</label>{{ firstForm.type }}</li>
              <li><label>上架方式：</label>{{ firstForm.storeMode }}</li>
              <li><label>原文类型：</label>
                <el-checkbox-group v-model="firstForm.fileTypes">
                  <el-checkbox disabled v-for="item in dict.type.TYPE" :label="item.value" :key="item.value">{{
                    item.label }}</el-checkbox>
                </el-checkbox-group>
              </li>
              <li><label>备&#160;注：</label>{{ firstForm.remark }}</li>
              <li><label>存储位置：</label>

                <el-input v-model="firstForm.filePath" placeholder="请输入内容"
                  style="margin-right:20px;text-align: left;"></el-input>
                <el-popover placement="top" width="">
                  <div>
                    <div v-for="(item, index) in historyList" :key="index" class="text item">
                      {{ item.filePath }}
                    </div>
                  </div>
                  <!-- <div style="text-align: right; margin: 0">
                    <el-button size="mini" type="text" @click="visible = false">取消</el-button>
                    <el-button type="primary" size="mini" @click="visible = false">确定</el-button>
                  </div> -->
                  <el-button slot="reference">历史位置</el-button>
                </el-popover>

                <!-- <el-button type="primary" size="mini" style="height:30px;margin-top:10px;margin-left:22px">历史位置</el-button> -->
              </li>
            </ul>
          </el-tab-pane>
          <el-tab-pane label="元数据方案信息" name="second">
            <el-form ref="secondForm" :rules="rulesForm" :model="secondForm" label-width="200px" style="margin-top:30px">
              <el-form-item label="方案名称" prop="nameValue">
                <el-select ref="name" v-model="secondForm.nameValue" placeholder="请选择方案" :disabled="isNameDisabled"
                  @change="changeSelectTap($event)">
                  <el-option v-for="item in nameOption" :key="item.value" :label="item.label"
                    :value="item.value"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="文件添加/修改页面列数" prop="wjcls">
                <el-select v-model="secondForm.wjcls" placeholder="请选择列数">
                  <el-option v-for="item in colNumOption" :key="item.value" :label="item.label"
                    :value="item.value"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="案卷添加/修改页面列数" prop="ajcls" v-show="isShowAj()">
                <el-select v-model="secondForm.ajcls" placeholder="请选择列数">
                  <el-option v-for="item in colNumOption" :key="item.value" :label="item.label"
                    :value="item.value"></el-option>
                </el-select>

              </el-form-item>
              <el-form-item label="项目添加/修改页面列数" prop="xmcls" v-show="isShowXm()">
                <el-select v-model="secondForm.xmcls" placeholder="请选择列数">
                  <el-option v-for="item in colNumOption" :key="item.value" :label="item.label"
                    :value="item.value"></el-option>
                </el-select>

              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="submitForm">保存</el-button>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <el-tab-pane label="元数据明细信息" name="five">
            <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
              <el-form-item label="显示名称" prop="fieldCaption">
                <el-input v-model="cateMdataQueryParams.fieldCaption" placeholder="请输入显示名称" clearable
                  @keyup.enter.native="cateMdataHandleQuery" />
              </el-form-item>
              <el-form-item label="字段名称" prop="fieldName">
                <el-input v-model="cateMdataQueryParams.fieldName" placeholder="请输入字段名称" clearable style="width: 240px"
                  @input="toUpperCase" @keyup.enter.native="cateMdataHandleQuery" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="cateMdataHandleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-select v-model="cateMdataQueryParams.type" style="width:140px" @change="cateMdataSelectTap($event)">
                  <el-option v-for="(dict, index) in deptOptionsRowType" :key="index" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-col>
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" @click="cateMdatahandleAdd">添加</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" @click="cateMdatahandleDelete"
                  :disabled="isUse == '1' ? true : false">删除</el-button>
              </el-col>

              <el-col :span="1.5">
                <batchOperation :ids="cateMdataIds" :isUse="null" :list="cateMdataList" :cateIsType="cateIsType"
                  @chanageFieldCaptionTap="chanageVatchOperationTap"></batchOperation>
              </el-col>

              <right-toolbar :showSearch.sync="showSearch" @queryTable="getCateMdataList"></right-toolbar>
            </el-row>
            <metadata :list="cateMdataList" :loading="cateMdataLoading"
              @handleSelectionChange="cateMdatahandleSelectionChange"
              :isUse="isUse" :isType="0" :tableHeight="tableHeight" :fieldlevel="cateMdataQueryParams.type"></metadata><!--@chanageFieldCaptionTap="getCateMdataList"-->

            <pagination v-show="cateMdataTotal > 0" :total="cateMdataTotal" :page.sync="cateMdataQueryParams.pageNum"
              :limit.sync="cateMdataQueryParams.pageSize" @pagination="getCateMdataList" />
          </el-tab-pane>
          <el-tab-pane label="档号定义" name="third">
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" @click="roleHandleAdd">新增规则</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-edit" @click="roleHandleUpdate">修改</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" @click="roleHandleDelete">删除</el-button>
              </el-col>
            </el-row>
            <el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChangeThird"
              :height="tableHeight">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="序号" type="index" :index="table_index" prop="id" />
              <el-table-column label="名称" prop="name" :show-overflow-tooltip="true" />
              <el-table-column label="开始时间" prop="starttime">
                <template slot-scope="scope">
                  {{ scope.row.starttime }}
                  <!--                  <span>{{ parseTime(scope.row.starttime, '{y}-{m}-{d}') }}</span>-->
                </template>
              </el-table-column>
              <el-table-column label="结束时间" prop="endtime">
                <template slot-scope="scope">
                  {{ scope.row.endtime }}
                  <!--                  <span>{{ parseTime(scope.row.endtime, '{y}-{m}-{d}') }}</span>-->
                </template>
              </el-table-column>
              <el-table-column label="是否默认" prop="isMoren">
                <template slot-scope="scope">
                  {{ scope.row.isMoren == '1' ? '是' : '否' }}
                </template>
              </el-table-column>
              <el-table-column label="规则明细" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-s-grid" @click="classifyTap()">分类方法</el-button>
                  <el-button type="text" icon="el-icon-plus" v-if="scope.row.fColumnname == null"
                    @click="detailHandleDeit(scope.row)" v-show="scope.row.fColumnname === null">新增</el-button>
                  <el-button type="text" icon="el-icon-edit" @click="detailHandleDeit(scope.row)"
                    v-show="scope.row.fColumnname !== null" v-else>修改</el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize" @pagination="getThirdList" />
          </el-tab-pane>
          <el-tab-pane label="应用定义" name="fourth">
            <el-form :model="queryParam" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
              <el-form-item label="模块名称" prop="menuName">
                <el-input v-model="queryParam.menuName" placeholder="请输入模块名称" clearable style="width: 240px"
                  @keyup.enter.native="handleQuery" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" @click="applyHandleAdd">新增模块</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" @click="applyHandleDelete">删除模块</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button plain icon="el-icon-document-copy" @click="applyCopy">复制到</el-button>
              </el-col>
              <right-toolbar :showSearch.sync="showSearch"></right-toolbar>
            </el-row>
            <el-table v-loading="loading" :data="applyList" @selection-change="handleSelectionChange"
              :height="tableHeight">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="序号" type="index" :index="table_index_apply" prop="MENU_ID" />
              <el-table-column label="模块名称" prop="MENU_NAME" :show-overflow-tooltip="true" />
              <el-table-column label="列表展示(列)" prop="roleKey" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'show')">启用</el-button>
                </template>
              </el-table-column>
              <el-table-column label="添加展示" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'add')">启用</el-button>
                </template>
              </el-table-column>
              <el-table-column label="修改展示" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'update')">启用</el-button>
                </template>
              </el-table-column>
              <el-table-column label="导出展示" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'export')">启用</el-button>
                </template>
              </el-table-column>
              <el-table-column label="查询条件" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'query')">启用</el-button>
                </template>
              </el-table-column>
              <el-table-column label="数据展示(行)" prop="roleSort">
                <template slot-scope="scope">
                  <el-button type="text" icon="el-icon-plus" @click="enableTap(scope.row, 'data')">启用</el-button>
                </template>
              </el-table-column>
            </el-table>
            <pagination v-show="applyTotal > 0" :total="applyTotal" :page.sync="queryParam.pageNum"
              :limit.sync="queryParam.pageSize" @pagination="getApplyList" />
          </el-tab-pane>
          <el-tab-pane label="归档范围和保管期限表" name="sex">
            <el-row :gutter="20">
              <el-col :span="5" :xs="24">
                <el-row :gutter="10" class="mb8" ref="hMain">
                  <el-col :span="1.5">
                    <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="treeZdAdd">新增</el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="success" plain icon="el-icon-edit" size="mini" @click="treeZdUpdate">修改</el-button>
                  </el-col>
                  <el-col :span="1.5">
                    <el-button type="danger" plain icon="el-icon-delete" size="mini" @click="treeZdDelete">删除</el-button>
                  </el-col>
                </el-row>

                <div class="head-container" style="overflow: auto">
                  <el-tree :data="gdfwandOptions" :props="defaultProps" :expand-on-click-node="false" ref="tree"
                    node-key="id" default-expand-all highlight-current @node-click="gdfwandNodeClick"
                    :filter-node-method="filterNode" :default-expanded-keys="expandedkeys"
                    :current-node-key="currentNodekey" :style="isSize" />
                </div>
              </el-col>
              <el-col :span="19" :xs="24">
                <el-table :data="tableZdData" border style="width: 100%">
                  <el-table-column type="index" label="序号" width="50" align="center" header-align="center">
                  </el-table-column>
                  <el-table-column prop="name" label="条款" width="500">
                  </el-table-column>
                  <el-table-column prop="bgqx" label="保管期限">
                    <template slot-scope="scope">
                      <div>
                        <span v-for="(i, idx) in dict.type.BGQX" :key="idx">
                          {{ scope.row.bgqx == i.value ? i.label : '' }}
                        </span>

                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column prop="address" label="操作">
                    <template slot-scope="scope">
                      <el-button type="primary" plain icon="el-icon-s-tools" round size="mini"
                        @click="setRuleTap(scope.row)">设置规则</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
            </el-row>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>

    <!-- 门类树的添加或修改用户配置对话框 -->
    <el-dialog :title="treeTitle" :visible.sync="treeOpen" width="30%" style="margin-top:4%" append-to-body>
      <el-form ref="treeForm" :model="treeForm" :rules="treeRules" label-width="100px">
        <el-form-item label="门类名称" prop="name">
          <el-input v-model="treeForm.name" placeholder="请输入名称" maxlength="30" />
        </el-form-item>

        <el-form-item label="档案库类型" prop="storeType">
          <el-select v-model="treeForm.storeType" placeholder="请选择档案库类型" style="width: 100%" class="el-selectTree">
            <el-option v-for="item in storeTypeOption" :key="item.value" :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="门类代码" prop="code">
          <el-input v-model="treeForm.code" placeholder="请输入门类代码" maxlength="30" />
        </el-form-item>

        <el-form-item label="整理方式" prop="type">
          <el-select v-model="treeForm.type" placeholder="请选择整理方式" style="width: 100%" class="el-selectTree"
            :disabled="isDisabled">
            <el-option v-for="item in typeOption" :key="item.value" :label="item.label" :value="item.value"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="上架方式" prop="storeMode">
          <el-select v-model="treeForm.storeMode" placeholder="请选择上架方式" style="width: 100%" class="el-selectTree"
            :disabled="isStoreModeDisabled">
            <el-option v-for="item in storeModeOption" :key="item.value" :label="item.label"
              :value="item.value"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="原文类型" prop="fileTypes">
          <el-checkbox-group v-model="treeForm.fileTypes">
            <el-checkbox v-for="dict in dict.type.TYPE" :label="dict.value" :key="dict.value">{{ dict.label
            }}</el-checkbox>
          </el-checkbox-group>
        </el-form-item>

        <el-form-item label="排序" prop="orderNo">
          <el-input-number style="width: 100%" v-model="treeForm.orderNo" controls-position="right" placeholder="请输入排序"
            :min="1" :max="500"></el-input-number>
        </el-form-item>

        <el-form-item label="备注" prop="remark">
          <el-input v-model="treeForm.remark" type="textarea" style="width: 100%" placeholder="请输入内容"></el-input>
        </el-form-item>
        <el-form-item label="存储位置" prop="filePath">
          <el-input v-model="treeForm.filePath" type="text" style="width: 100%" placeholder="请输入存储位置"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitTrreForm">保 存</el-button>
        <el-button @click="treeCancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 档号定义规则的新增或修改规则 -->
    <defineRule :roleOpen="roleOpen" @roleCancel="roleCancelTap" @submitRoleForm="submitRoleForm" :roleTitle="roleTitle"
      ref="defineRuleref"></defineRule>
    <!-- 档号定义规则明细的新增或修改规则 -->
    <ruleDetails v-if="detailOpen" :detailOpen="detailOpen" :roleRow="roleRow" @resetRoleCancel="resetRoleCancel"
      @submitDetail="submitDetail">
    </ruleDetails>
    <!-- 档号定义规则明细排序的新增或修改规则 -->

    <!-- 应用定义的新增模块或修改规则 -->
    <applicationDefinition :applyTitle="applyTitle" :applyOpen="applyOpen" @applyCancel="applyCancel"
      @submitApply="submitApply" ref="applyref"></applicationDefinition>

    <transFer :title="ApplyDetailTitle" :dataChecked="myDataChecked" :cities="ApplyDetailData"
      @determine="submitApplyDetail" @closeFilter="closeApply" :open="applyDetailOpen" :IsXmDetail="IsXmDetail"
      @XmDetail="XmDetail" :IsJuanDetail="IsJuanDetail" @JuanDetail="JuanDetail" :IsJianDetail="IsJianDetail"
      @JianDetail="JianDetail" :IsDzwjDetail="IsDzwjDetail" @DzwjDetail="DzwjDetail" :isShowOrder="isShowOrder">
    </transFer>


    <mdataAdd v-if="cateMdataOpen == true" ref="dialogRef" :cateMdataOpen="cateMdataOpen"
      @closeMdataDelDialog="closeMdataDelDialog" :addParams="addParams"></mdataAdd>


    <!-- 设置规则 -->
    <setRule v-if="setRuleOpen == true" :setRuleOpen="setRuleOpen" @closeSetRuleDialog="closeSetRuleDialog"
      :addParams="addParams"></setRule>

    <!-- 分类方法 -->
    <classify v-if="classifyOpen == true" :classifyOpen="classifyOpen" :deptOptionsRowType="deptOptionsRowType"
      @closeClassifyDialog="closeClassifyDialog" :addParams="addParams"></classify>

    <!-- 制度添加修改 -->
    <zdTreeDeit v-if="zdTreeDeitOpen == true" :zdTreeDeitOpen="zdTreeDeitOpen"
      @closezdTreeDeitDialog="closezdTreeDeitDialog" @submitzdTrreForm="submitzdTrreForm" :addParams="addParams">
    </zdTreeDeit>
  </div>
</template>
<script>
import {
  listGROUPTree,
  addGroupTree,
  getGroupTree,
  updateGroupTree,
  delGroupTree,
  syncGroupTree,
  metaData,
  saveMetaData,
  getMetaData,
  getCodeRule,
  delCodeRole,
  cateMdataList, getApply, delApply, delArrApply, delcateMdata, fieldlist, addApplyDetail, gdfwandbgqxTree, gdfwandbgqxEditzd, getzd, gettable, yqdaFilePathHistory
} from "@/api/archive/archivesCategory.js";
import { getInfo } from "@/api/login";
import { listDictData } from "@/api/manage/dict/dictManage";
import transFer from "@/components/transFer/index.vue"
import estimateTableHeight from '@/mixins/estimateTableHeight'//vue项目中element-tabel自动计算高度
import metadata from "@/components/mdataList/index.vue"  //元数据明细信息列表
import mdataAdd from "@/components/mdataList/mdataAdd.vue"//元数据明细信息列表添加
import batchOperation from "@/components/mdataList/BatchOperation.vue" //元数据明细信息列表批量操作
import defineRule from "@/views/archive/application/archivesCategory/defineRule.vue";//档号规则
import ruleDetails from "@/views/archive/application/archivesCategory/ruleDetails.vue";//档号规则
import applicationDefinition from "@/views/archive/application/archivesCategory/applicationDefinition"; //应用定义
import setRule from "@/views/archive/application/archivesCategory/setRule.vue"; //设置规则
import classify from "@/views/archive/application/archivesCategory/classify.vue"; //分类方法
import zdTreeDeit from "@/views/archive/application/archivesCategory/zdTreeDeit.vue"; //制度数添加修改
export default {
  components: {
    metadata,
    mdataAdd,
    batchOperation,
    defineRule,
    ruleDetails,
    applicationDefinition,
    transFer,
    setRule,
    classify,
    zdTreeDeit
  },
  archive_Dicts: ['TYPE', 'BGQX'],
  mixins: [estimateTableHeight], // 混入方法
  data() {
    const checkType = (rule, value, callback) => {
      if ((this.treeForm.type === '1' || this.treeForm.type === '3') && value === '') {
        callback(new Error('请选择上架方式'));
      } else {
        callback();
      }
    }
    const inputName = (rule, value, callback) => {
      if (value.trim() === '') {
        callback(new Error('输入不能为空格'));
      } else {
        callback();
      }
    }
    return {
      tableData: [{
        date: '1',
        name: '王小虎',
        address: '10年'
      }, {
        date: '2',
        name: '王小虎',
        address: '10年'
      }, {
        date: '3',
        name: '王小虎',
        address: '10年'
      }, {
        date: '4',
        name: '王小虎',
        address: '10年'
      }],
      cateIsType: "0",
      roleDetail: "1",
      title: "档号规则明细",
      // 应用定义菜单
      applyOption: [],
      sortData: [],
      // sortorder: [],
      input: "-",
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 档号表格数据
      roleList: [],
      // 应用定义表格数据
      applyList: [],
      // 部门树选项
      deptOptions: undefined,
      defaultProps: {
        children: "children",
        label: "label"
      },
      //tabs标签切换默认选择项
      activeName: 'first',
      //多选框是否勾选
      checkList: ['附件'],
      dialogFormVisible: true,
      historyList: [],//历史位置
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 15
      },
      queryParam: {
        pageNum: 1,
        pageSize: 10,
        menuName: ""
      },
      applyTotal: 0,
      //应用模块
      applyDetailData: [],
      ApplyDetailData: [],
      //默认展开的树节点
      expandedkeys: [],
      //默认选中的树节点
      currentNodekey: "",
      //门类树是否显示弹出层
      treeOpen: false,
      //门类树弹出层(标题)
      treeTitle: "",
      //档号定义规则是否显示弹出层
      roleOpen: false,
      //档号定义规则弹出层
      roleTitle: "",
      //档号定义规则判断是添加还是修改
      isEvent: "",
      //档号定义规则明细是否显示弹出层
      detailOpen: false,

      //应用定义是否显示弹出层
      applyOpen: false,
      // 应用定义操作
      applyOperate: "",
      // 应用定义明细是否显示弹出层
      applyDetailOpen: false,
      //应用定义弹出层
      applyTitle: "",
      // 展示启用
      enableOperate: '',
      // 菜单id
      menuID: '',
      // 展示弹窗
      ApplyDetailTitle: "应用定义明细",
      // 应用定义展示右侧数据
      myDataChecked: [],
      IsXmDetail: false,
      IsJuanDetail: false,
      IsJianDetail: false,
      IsDzwjDetail: false,
      isShowOrder: false,

      //树表单参数
      treeForm: {
      },


      // 档号定义排序表单参数
      sortForm: {},
      digit: "",
      ziduanStart: [],
      fuhaoarr: [],
      ziduanEnd: "",
      // 应用定义表单参数
      applyForm: {},
      createor: "",
      createtime: "",
      //门类整理方式：添加可以编辑，修改时禁止编辑
      isDisabled: false,
      //门类上架方式：添加可以编辑，修改时禁止编辑
      isStoreModeDisabled: false,
      // 元数据方案未保存可以选择,保存后禁止选择
      isNameDisabled: false,
      //树表单校验
      treeRules: {
        name: [
          { required: true, message: '门类名称不能为空', trigger: 'blur' },
          { trigger: 'blur', validator: inputName }
        ],
        storeType: [
          { required: true, message: '档案库类型不能为空', trigger: 'blur' }
        ],
        code: [
          { required: true, message: '门类代码不能为空', trigger: 'blur' },
          {
            pattern: /^[A-Za-z0-9_·]+$/,
            message: "请输入数字、字母‘_’或‘·’",
            trigger: "blur"
          },
          { trigger: 'blur', validator: inputName }
        ],
        storeMode: [
          { trigger: 'change', validator: checkType },
          { required: true, message: '请选择上架方式', trigger: 'blur' }
        ],
        type: [
          { required: true, message: '请选择整理方式', trigger: 'blur' }
        ],
        fileTypes: [
          { type: 'array', required: true, message: '请至少选择一个原文类型', trigger: 'blur' }
        ]

      },
      // 档号定义规则表单校验
      roleRules: {
        name: [
          { required: true, message: '名称不能为空', trigger: 'blur' }
        ],
        starttime: [
          { required: true, message: '开始时间不能为空', trigger: 'blur' }
        ],
        endtime: [
          { required: true, message: '结束时间不能为空', trigger: 'blur' }
        ]
      },
      // 门类树添加---档案库类型下拉
      storeTypeOption: [
        { value: 't', label: '文本类' },
        { value: 'p', label: '照片类' },
        { value: 'v', label: '视频类' },
        { value: 'm', label: '录音类' },
        { value: 'o', label: '其他类' },
        { value: 'l', label: '蓝图类' },
        { value: 'd', label: '底图类' },
        { value: 'j', label: '检察类' },
        { value: 'g', label: '过程文件类' }
      ],
      // 门类树添加---整理方式下拉
      typeOption: [
        { value: '1', label: '组卷' },
        { value: '0', label: '组件' },
        { value: '3', label: '项目' },
      ],
      // 门类树添加---原文类型
      // fileTypesOption: [
      //   { value: '1', label: '正文' },
      //   { value: '2', label: '文稿' },
      //   { value: '3', label: '报批件' },
      //   { value: '4', label: '附件' }
      // ],
      // 门类信息---上架方式
      storeModeOptions: [
        { value: '2', label: '按盒上架' },
        { value: '1', label: '按卷上架' }
      ],
      fileTypes: [],
      // 门类表单参数
      firstForm: {

      },
      // 元数据方案信息参数
      secondForm: {},
      // 元数据方案
      nameOption: [],

      // 规则字段
      ziduanSOption: [],
      ziduanEOption: [],
      jianziduanOption: [],
      jianOption: [],
      // 元数据方案type
      metaType: '',
      // 元数据方案---列数选择
      colNumOption: [
        { value: '2', label: '2' },
        { value: '3', label: '3' }
      ],
      // 非单个禁用
      single: true,
      applySingle: true,
      applyIds: [],
      applyName: [],
      // 非多个禁用
      multiple: true,
      applyMultiple: true,
      roleorder: 'asc', // 默认升序
      roleRow: '', //点击新增修改获取规则列表当前行数据
      isarr: [], //判断
      operate: '',
      //恢复默认值form
      restoreForm: {},
      //规则明细按钮标识
      fColumnname: "",
      isfondsCode: false, //判断如果是全宗就不显示右侧tabs的数据
      //元数据方案明细列表遮罩层
      cateMdataLoading: true,
      //元数据方案明细列表
      cateMdataList: [],
      //元数据方案明细列表总条数
      cateMdataTotal: 0,
      //元数据方案明细列表判断当前按钮是否可用
      isUse: "",
      // 元数据方案明细选中数组
      cateMdataIds: "",
      cateMdataLabel: [],
      //元数据方案明细查询参数
      cateMdataQueryParams: {
        pageNum: 1,
        pageSize: 10,
        fieldCaption: undefined,
        fieldName: undefined,
        categoryId: undefined,
        groupId: undefined,
        type: undefined,
      },
      //元数据方案明细类型下拉
      deptOptionsRowType: undefined,
      //元数据方案明细弹出层
      cateMdataOpen: false,
      addParams: "",
      //批量操作
      ticketsform: {
        isInput: undefined, //是否可录入0=否,1=是
        isUpdate: undefined, //是否可修改0=否,1=是
        isArchiveNo: undefined, //是否档号字段0=否,1=是
        isNoEmpty: undefined, //是否非空0=否,1=是
        isHidden: undefined, //是否隐藏0=否,1=是
        isExport: undefined, //是否可导出0=否,1=是
        isMetadata: undefined, //是否元数据0=否,1=是
      },
      treeNode: "",
      rulesForm: { //元数据方案信息校验
        nameValue: [
          { required: true, message: '请选择方案', trigger: 'blur' },
        ],
      },
      rowData: [],
      tableHeight: "",
      setRuleOpen: false,//设置规则弹窗
      classifyOpen: false,//分类方法弹窗
      zdTreeDeitOpen: false,//制度树添加修改
      gdfwandOptions: undefined,//制度树列表
      parentId: undefined,//获取当前点击制度树的ID
      deitInfo: "",//制度树修改信息
      tableZdData: [],//制度列表
    }
  },
  created() {
    this.getDeptTree();
    this.tableHeightData();
  },
  computed: {
    storeModeOption() {
      if (this.treeForm.type == '0') {
        this.treeForm.storeMode = '2'
        return [{ value: '2', label: '按盒上架' }]
      } else {
        return [
          { value: '2', label: '按盒上架' },
          { value: '1', label: '按卷上架' }
        ]
      }
    },
    isSize() {

      if (this.$store.getters.size == 'small') {
        this.size = 'font-size: 12px;'
      } else {
        this.size = 'font-size: 14px;'
      }
      return this.size
    }
  },
  methods: {



    //动态设置table的高度
    tableHeightData() {
      this.$nextTick(
        () => {
          let h = document.documentElement.clientHeight
          //     console.log(this.$refs.queryForm.$el.offsetHeight, this.$refs.refbut.$el.offsetHeight, "sdklfjklliuhaiorng")
          h = h - 360
          if (this.$refs.queryForm) { // 页面上如果有面包屑区域徐减去它的高度
            h = h - this.$refs.queryForm.$el.offsetHeight
          }

          if (this.$refs.refbut) { // 页面上如果有分页区域徐减去它的高度
            h = h - this.$refs.refbut.$el.offsetHeight
          }
          // console.log(h,"sdjfdklsjfkl")
          this.tableHeight = h > 310 ? h : 310 // 根据自己项目定高度

          return h
        }
      )

    },
    table_index(index) {
      return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
    },
    table_index_apply(index) {
      return (this.queryParam.pageNum - 1) * this.queryParam.pageSize + index + 1;
    },
    isShowAj() {
      return this.metaType === '1' || this.metaType === '3'
    },
    isShowXm() {
      return this.metaType === '3'
    },
    isShowDh() {
      return this.digit > 0
    },
    isRestore() {
      if (this.operate == 'update') {
        return true;
      } else {
        return false;
      }
    },
    // 表单重置
    reset() {
      this.treeForm = {
        name: undefined,
        storeType: undefined,
        code: undefined,
        type: null,
        storeMode: undefined,
        fileTypes: [],
        orderNo: undefined,
        remark: undefined,
        fondsCode: undefined,
        filePath: undefined
      };
    },
    // 门类信息表单重置
    resetFirst() {
      this.firstForm = {
        name: undefined,
        code: undefined,
        storeType: undefined,
        type: null,
        storeMode: undefined,
        fileTypes: [],
        remark: undefined
      }
    },
    // 元数据方案信息表单重置
    resetSecond() {
      this.secondForm = {
        name: undefined,
        nameValue: undefined,
        wjcls: undefined,
        ajcls: undefined,
        xmcls: undefined,
        type: undefined,
        id: undefined,
        groupId: undefined
      }
    },

    // 点击标签页时方法
    handleTabClick(tab) {
      if (tab.name == 'five') {
        this.getCateMdataList(); //获取元数据明细信息列表
      } else if (tab.name == 'fourth') {
        this.getApplyTrans() //获取应用定义弹窗数据
      } else if (tab.name == 'sex') {
        this.gdfwandbgqxTreePost();//制度树列表
      }
      this.tableHeightData()
    },

    // 获取门类信息渲染门类信息标签页
    getFirstList() {
      this.resetFirst();
      getGroupTree(this.queryParams.id).then(response => {
        if (response.data !== undefined) {
          this.firstForm = response.data;
          if (response.data.fileTypes !== null) {
            this.firstForm.fileTypes = response.data.fileTypes.split(',');
          } else {
            this.firstForm.fileTypes = []
          }
          const option = this.storeTypeOption.find(option => option.value === response.data.storeType);
          this.firstForm.storeType = option ? option.label : '';
          this.metaType = response.data.type.toString()
          this.getSecondList();
          const option1 = this.typeOption.find(option => option.value === response.data.type.toString());
          this.firstForm.type = option1 ? option1.label : '';
          const option2 = this.storeModeOptions.find(option => option.value === response.data.storeMode.toString());
          this.firstForm.storeMode = option2 ? option2.label : '';
        }
      });
    },
    /** 查询树结构 */
    getDeptTree() {
      listGROUPTree().then(response => {
        this.deptOptions = response.data;
        if (this.deptOptions.length > 0) {
          console.log(this.deptOptions)
          this.currentNodeKey = this.deptOptions[0].children[0].id;
          this.expandedkeys.push(this.deptOptions[0].children[0].id);
          this.$nextTick(() => {
            if (this.$refs.tree) {
              this.$refs.tree.setCurrentKey(this.deptOptions[0].children[0].id)
            }
          })
          // 门类id
          this.queryParams.id = response.data[0].children[0].id;
          //元数据方案的fondsCode
          this.queryParams.fondsCode = response.data[0].children[0].fondsCode;
          // 元数据方案id
          this.queryParams.groupId = response.data[0].children[0].groupId
          //获取树的type==null ,不显示右侧数据
          this.isfondsCode = false
          if (response.data[0].children[0].type != null) {
            this.isfondsCode = true
          }
          // else{
          //   this.queryParams.type = response.data[0].children[0].type.toString();
          // }

          // this.getFirstList();
          // this.getSecondList();
          this.getThirdList();
        }
      });
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      console.log(data, "+++")
      this.rowData = data;
      this.isfondsCode = data.type == null ? false : true; //判断右侧模块显示无数据还是有数据
      this.treeNode = data;
      this.queryParams.id = data.id; //门类id
      this.queryParams.fondsCode = data.fondsCode;
      this.queryParams.groupId = data.groupId// 元数据方案id
      if (this.isfondsCode) {
        this.activeName = 'first'
        this.getFirstList();  //获取门类信息
        this.getSecondList(); //获取元数据方案信息
        this.getThirdList();
        this.getApplyList(); //获取应用定义表格
        this.historyTap1();
        /*start 获取元数据明细信息*/
        this.cateMdataQueryParams.categoryId = data.id;//门类id
        this.cateMdataQueryParams.groupId = data.groupId;//门类groupId
        this.cateMdataQueryParams.type = data.type.toString();//门类类型
        this.cateMdataQueryParams.fieldCaption = undefined;
        this.cateMdataQueryParams.fieldName = undefined;
        this.cateMdataQueryParams.pageNum = 1
        this.cateMdataQueryParams.pageSize = 10
        this.queryParams.type = data.type.toString();
        this.queryParam.menuName = undefined;
        this.queryParam.pageNum = 1
        this.queryParam.pageSize = 10
        console.log(this.$refs['secondForm'],"dksfjsdk")
        if(this.$refs['secondForm']!=undefined){
          this.$refs['secondForm'].resetFields();
        }

        // this.getApplyTrans() //获取应用定义弹窗数据
        if (data.type == 0) {
          this.deptOptionsRowType = [
            { value: '0', label: '件层' },
            { value: '2', label: '电子文件层' },
          ]
        } else if (data.type == 1) {
          this.deptOptionsRowType = [
            { value: '1', label: '卷层' },
            { value: '0', label: '件层' },

            { value: '2', label: '电子文件层' },
          ]
        } else {
          this.deptOptionsRowType = [
            { value: '3', label: '项目层' },
            { value: '1', label: '卷层' },
            { value: '0', label: '件层' },
            { value: '2', label: '电子文件层' },

          ]
        }
        this.gdfwandbgqxTreePost();//回档范围和保管期限
        this.tableZdData=[];
      }
    },
    //历史位置
    historyTap1() {
      yqdaFilePathHistory(this.queryParams.id).then(response => {

        if (response.code == "200") {

          this.historyList = response.data

        }


      })



    },
    //档案门类树添加
    treeHandleAdd() {
      var that = this;
      if (this.queryParams.fondsCode != null) {
        that.treeOpen = true;
        this.isDisabled = false;
        that.treeTitle = "添加门类";
        this.isStoreModeDisabled = false
        this.reset();
      } else {
        this.$message({ message: '只能给全宗下进行增加门类哦', type: 'warning' })
      }
    },
    //档案门类树修改
    treeHandleUpdate() {
      this.reset();

      getGroupTree(this.queryParams.id).then(response => {
        this.treeForm = response.data;
        if (response.data.fileTypes !== null) {
          this.treeForm.fileTypes = response.data.fileTypes.split(',');
        } else {
          this.treeForm.fileTypes = []
        }
        this.treeForm.type = response.data.type.toString();
        this.treeForm.storeMode = response.data.storeMode.toString();
        this.treeOpen = true;
        this.isDisabled = true;
        this.isStoreModeDisabled = true;
        this.treeTitle = "修改门类";
      });
    },
    //门类树添加提交
    submitTrreForm() {
      this.$refs["treeForm"].validate((valid) => {
        if (valid) {
          console.log(this.treeForm)
          if (this.treeForm.id != undefined) {
            this.treeForm.fileTypes = this.treeForm.fileTypes.toString()
            this.treeForm.type = parseInt(this.treeForm.type)
            this.treeForm.storeMode = parseInt(this.treeForm.storeMode)
            updateGroupTree(this.treeForm).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.treeOpen = false;
              this.$refs["treeForm"].resetFields();
              this.$refs["treeForm"].clearValidate();
              this.getDeptTree();
            });
          } else {
            this.treeForm.fileTypes = this.treeForm.fileTypes.toString()
            this.treeForm.type = parseInt(this.treeForm.type)
            this.treeForm.storeMode = parseInt(this.treeForm.storeMode)
            this.treeForm.fondsCode = this.queryParams.fondsCode;
            addGroupTree(this.treeForm).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.treeOpen = false;
              this.$refs["treeForm"].resetFields();
              this.$refs["treeForm"].clearValidate();
              this.getDeptTree();
            });
          }
        }
      })
    },
    //门类树修改取消
    treeCancel() {
      var that = this;
      that.treeOpen = false;
      this.$refs["treeForm"].resetFields();
      this.$refs["treeForm"].clearValidate();
    },

    //规则明细新增和修改关闭
    resetRoleCancel() {
      this.detailOpen = false;
    },
    // 档号定义---规则明细添加和修改提交
    submitDetail() {
      this.detailOpen = false;
      this.getThirdList();
    },

    //档案门类树 删除
    treeHandleDelete() {
      this.$modal.confirm('是否确认删除当前的数据项？').then(function () { }).then(() => {
        delGroupTree(this.queryParams.id).then(res => {
          if (res.code == "200") {
            this.$modal.msgSuccess("删除成功");
            this.getDeptTree();
          }
        })


      }).catch(() => { });
    },
    treeHandleSync() {
      this.$modal.confirm('是否确认将主表结构同步到长期保存？').then(function () { }).then(() => {
        syncGroupTree().then(res => {
          if (res.code == "200") {
            this.$modal.msgSuccess("同步成功");
          }
        })


      }).catch(() => { });
    },
    // 获取元数据方案下拉框
    fetchData() {
      this.resetSecond();
      if (this.metaType != '') {
        this.form = {
          isUse: '0',
          type: this.metaType
        }
        metaData(this.form).then(response => {
          this.nameOption = response.data.map(option => {
            return {
              value: option.id,
              label: option.name,
              type: option.type,
            }
          })
          if (this.nameOption.length > 0) {
            // this.secondForm.nameValue = this.nameOption[0].value;
            // this.secondForm.name = this.nameOption[0].label;
            // this.secondForm.groupId = this.nameOption[0].value;
            // this.secondForm.type = this.nameOption[0].type;
          }
          if (this.metaType === '0') {
            this.secondForm.wjcls = '2'
          } else if (this.metaType === '1') {
            this.secondForm.ajcls = '2'
            this.secondForm.wjcls = '2'
          } else if (this.metaType === '3') {
            this.secondForm.xmcls = '2'
            this.secondForm.ajcls = '2'
            this.secondForm.wjcls = '2'
          }
        })
      }
    },
    // 元数据方案下拉框选中事件
    changeSelectTap(data) {
      var dataRow = this.nameOption.filter((item) => {
        return item.value == data
      })
      this.secondForm.name = dataRow[0].label;
      this.secondForm.groupId = dataRow[0].value;
      this.secondForm.type = dataRow[0].type;
    },
    // 保存元数据方案信息
    submitForm() {
      console.log(this.secondForm, "ksdfjksdljflsdjfkl")
      this.$refs.secondForm.validate((valid) => {
        if (valid) {
          this.secondForm.id = this.queryParams.id;
          if (this.metaType == '0') {
            this.secondForm.wjcls = parseInt(this.secondForm.wjcls)
            this.secondForm.ajcls = 0;
            this.secondForm.xmcls = 0;
          } else if (this.metaType == '1') {
            this.secondForm.xmcls = 0
            this.secondForm.ajcls = parseInt(this.secondForm.ajcls)
            this.secondForm.wjcls = parseInt(this.secondForm.wjcls)
          } else {
            this.secondForm.ajcls = parseInt(this.secondForm.ajcls)
            this.secondForm.wjcls = parseInt(this.secondForm.wjcls)
            this.secondForm.xmcls = parseInt(this.secondForm.xmcls)
          }

          this.cateMdataQueryParams.groupId = this.secondForm.groupId;
          saveMetaData(this.secondForm).then(response => {
            this.$modal.msgSuccess("保存成功");
            this.isNameDisabled = true;
            //主要实现点击档案树   元方案数据回显功能
            for (var j = 0; j < this.deptOptions[0].children.length; j++) {
              if (this.deptOptions[0].children[j].children != undefined) {
                for (var i = 0; i < this.deptOptions[0].children[j].children.length; i++) {
                  if (this.deptOptions[0].children[j].children[i].id === this.secondForm.id) {
                    this.deptOptions[0].children[j].children[i].groupId = this.secondForm.groupId
                  }
                }
              }
            }
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });




    },
    // 获取信息渲染元数据方案信息标签页
    getSecondList() {
      this.resetSecond();
      if (this.queryParams.groupId !== undefined && this.queryParams.groupId !== null) {
        //获取元数据方案信息
        getMetaData(this.queryParams.groupId).then(response => {
          this.secondForm.groupId = response.data.id;
          this.secondForm.name = response.data.name;
          this.secondForm.nameValue = response.data.name;
          this.secondForm.type = response.data.type;
          this.isNameDisabled = true
          if (this.metaType === '0') {
            this.secondForm.wjcls = response.data.wjColLength
          } else if (this.metaType === '1') {
            this.secondForm.ajcls = response.data.ajColLength
            this.secondForm.wjcls = response.data.wjColLength
          } else {
            this.secondForm.xmcls = response.data.xmColLength
            this.secondForm.ajcls = response.data.ajColLength
            this.secondForm.wjcls = response.data.wjColLength
          }
        })
      } else {
        this.isNameDisabled = false
        this.fetchData(); //获取元数据方案下拉框
      }
    },
    // 档号定义多选框选中数据
    handleSelectionChangeThird(selection) {
      this.ids = selection.map(item => item.id)
      this.thirdName = selection.map(item => item.name)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    // 获取档号定义列表
    getThirdList() {
      this.operate = ""
      this.loading = true;
      this.form = {
        categoryModelId: this.queryParams.id
      }
      getCodeRule(this.form).then(response => {
        // console.log(response,"lsdkfjkl_________")
        this.roleList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 档号定义---新增规则
    roleHandleAdd() {
      this.roleOpen = true;
      this.roleTitle = "新增档案规则信息";
      this.isEvent = "";
      this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
        this.$refs.defineRuleref.init(this.isEvent, this.queryParams.id);     //获取子组件中init方法并将父组件id传递给子组件
      });
    },
    // 档号定义---修改规则
    roleHandleUpdate(row) {
      if (this.single == false) {
        const roleId = row.id || this.ids
        this.isEvent = roleId.toString()
        this.roleOpen = true;
        this.roleTitle = "修改档案规则信息";
        this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
          this.$refs.defineRuleref.init(this.isEvent);     //获取子组件中init方法并将父组件id传递给子组件
        });
      } else {
        this.$message({ message: '请选择一条数据进行修改哦', type: 'warning' })
      }
    },
    //档号定义规则取消
    roleCancelTap() {
      this.roleOpen = false;
    },

    //新增修改档号定义规则
    submitRoleForm() {
      this.roleOpen = false;
      this.getThirdList();
    },
    // 档号定义---删除规则
    roleHandleDelete(row) {
      const roleId = row.id || this.ids
      const label = row.name || this.thirdName
      if (roleId.length > 0) {
        this.$modal.confirm('是否确认删除规则名称为"' + label + '"的数据项？').then(function () {
          return delCodeRole(roleId);
        }).then(() => {
          this.getThirdList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => { });
      } else {
        this.$message({ message: '请选择一条数据删除哦', type: 'warning' })
      }
    },

    // 档号定义---新增修改规则明细
    detailHandleDeit(row) {
      this.detailOpen = true
      var type = ''
      if (this.treeNode.type.toString() == '0') {
        type = '0'
      } else {
        type = '1'
      }
      var dataArr = {
        row: row,
        categoryId: this.treeNode.id,//门类id
        groupId: this.treeNode.groupId,//门类groupId
        type: type,//门类类型
      }
      this.roleRow = dataArr
    },


    /****start   应用定义 */

    //搜索按钮操作
    handleQuery() {
      this.queryParam.pageNum = 1;
      this.getApplyList();
    },
    //应用定义重置按钮
    resetQuery() {
      this.resetForm("queryForm");
      this.cateMdataQueryParams.fieldCaption = undefined;
      this.cateMdataQueryParams.fieldName = undefined;
      this.cateMdataQueryParams.pageNum = 1;
      this.cateMdataQueryParams.pageSize = 10;
      if (this.activeName == "five") {
        this.getCateMdataList(); //元数据方案明细
      } else if (this.activeName == 'fourth') {
        this.getApplyList() // 应用定义
      } else if (this.activeName == 'sex') {
        this.gdfwandbgqxTreePost();//制度树列表
      }
      if (this.rowData.length == undefined) {
        this.queryParams.type = this.rowData.type.toString();
      } else {
        this.queryParams.type = this.deptOptions[0].children[0].type.toString();
      }
    },
    //应用模块取消
    applyCancel() {
      this.applyOpen = false
    },
    //应用定义新增模块
    applyHandleAdd() {
      this.applyTitle = "新增模块"
      this.isEvent = "";
      this.applyOpen = true
      this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
        this.$refs.applyref.init(this.isEvent, this.queryParams.id);     //获取子组件中init方法并将父组件id传递给子组件
      });

    },
    handleSelectionChange(selection) {
      this.applyIds = selection.map(item => item.MENU_ID)
      this.applyName = selection.map(item => item.MENU_NAME)
      this.applySingle = selection.length != 1
      this.applyMultiple = !selection.length
    },
    //应用定义删除模块
    applyHandleDelete(row) {
      var that = this;
      if (this.applyMultiple == false) {
        const categoryId = this.queryParams.id
        this.$modal.confirm("是否确认删除应用模块菜单所选的数据项？").then(function () {
          delArrApply({
            categoryId: categoryId,
            menuIds: that.applyIds
          }).then(res => {
            that.getApplyList();
            that.$modal.msgSuccess("删除成功");
          }).catch(() => {

          })
        })
      } else {
        this.$message({ message: '请选择条数据进行删除', type: 'warning' })
      }
    },
    // 复制到
    applyCopy(row) {
      if (this.applySingle == false) {
        const clonedmenuId = row.MENU_ID || this.applyIds
        this.isEvent = clonedmenuId.toString()
        this.applyOpen = true
        this.applyTitle = "复制模块"
        this.$nextTick(() => {   //此函数执行时所有的DOM挂载和渲染都已完成
          this.$refs.applyref.init(this.isEvent, this.queryParams.id);     //获取子组件中init方法并将父组件id传递给子组件
        });
      } else {
        this.$message({ message: '请选择一条数据进行修改哦', type: 'warning' })
      }
    },
    // 应用定义穿梭框
    getApplyTrans() {
      if (this.queryParams.type == 0) {
        this.IsDzwjDetail = true
        this.IsJianDetail = false
        this.IsJuanDetail = false
        this.IsXmDetail = false
      } else if (this.queryParams.type == 1) {
        this.IsJianDetail = true
        this.IsDzwjDetail = true
        this.IsJuanDetail = false
        this.IsXmDetail = false
      } else if (this.queryParams.type == 3) {
        this.IsJuanDetail = true
        this.IsJianDetail = true
        this.IsDzwjDetail = true
        this.IsXmDetail = false
      }
      // 由于接口是元数据明细分页查询  所以pageSize传值200
      // this.form = {
      //   categoryId: this.cateMdataQueryParams.categoryId,
      //   groupId: this.cateMdataQueryParams.groupId,
      //   type: this.cateMdataQueryParams.type,
      //   pageNum: 1,
      //   pageSize: 200,
      // }
      // cateMdataList(this.form).then(response => {
      //   this.applyDetailData = response.rows.map((item, index) => {
      //     return {
      //       fieldCaption: item.fieldCaption,
      //       fieldName: item.fieldName,
      //       isOrder: 'asc',
      //       key: index
      //     }
      //   })
      // })
    },

    enableTap(row, enableOperate) {
      var that = this;
      that.ApplyDetailData = [];

      this.enableOperate = enableOperate
      var datai=""
      if (this.enableOperate == 'show') {
        this.form.isHidden = 0;
        datai="isHidden"
      }
      if (this.enableOperate == 'add') {
        this.form.isInput = 1;
        datai="isInput"
      }
      if (this.enableOperate == 'update') {
        this.form.isUpdate = 1;
        datai="isUpdate"
      }
      if (this.enableOperate == 'export') {
        this.form.isExport = 1;
        datai="isExport"
      }
      if (this.enableOperate == 'query') {
        this.form.isQuery = 10;
        datai="isQuery"
      }
      if (this.enableOperate == 'data') {
        this.form.isHidden = 0;
        datai="isHidden"
      }
      console.log(this.form[datai],Object.keys(this.form[datai]),"sdkfjklsdjfklsdjf")
      this.menuID = row.MENU_ID
      this.applyDetailOpen = true
      if (enableOperate == 'data') {
        this.isShowOrder = true
      } else {
        this.isShowOrder = false
      }
      this.myDataChecked = []
      this.getApplyTrans()
      // 由于接口是元数据明细分页查询  所以pageSize传值200
      this.form = {
        categoryId: this.cateMdataQueryParams.categoryId,
        groupId: this.cateMdataQueryParams.groupId,
        type: this.queryParams.type,
        pageNum: 1,
        pageSize: 200,
        [datai]:this.form[datai]

      }
      var arrArrylist = [];
      cateMdataList(this.form).then(response => {

        arrArrylist = response.rows.map((item, index) => {
          return {
            fieldCaption: item.fieldCaption,
            fieldName: item.fieldName,
            isOrder: 'asc',
            key: index
          }
        })

        var field = ""
        if (enableOperate == "show") {
          if (this.metaType == 0) {
            field = "jianlistfield"
          } else if (this.metaType == 1) {
            field = "juanlistfield"
          } else if (this.metaType == 3) {
            field = "xiangmulistfield"
          }
        } else if (enableOperate == 'query') {
          if (this.metaType == 0) {
            field = "jianquery"
          } else if (this.metaType == 1) {
            field = "juanquery"
          } else if (this.metaType == 3) {
            field = "xiangmuquery"
          }
        } else if (enableOperate == 'data') {
          if (this.metaType == 0) {
            field = "jianorder"
          } else if (this.metaType == 1) {
            field = "juanorder"
          } else if (this.metaType == 3) {
            field = "xiangmuorder"
          }
        } else {
          if (this.metaType == 0) {
            field = "jian" + enableOperate + "field";
          } else if (this.metaType == 1) {
            field = "juan" + enableOperate + "field";
          } else if (this.metaType == 3) {
            field = "xiangmu" + enableOperate + "field";
          }
        }

        this.form = {
          menuId: this.menuID,
          categoryId: this.cateMdataQueryParams.categoryId,
          field: field
        }
        this.getApplyXinxi(this.form, this.enableOperate, arrArrylist)
      })
    },

    // 获取应用定义启用信息
    getApplyXinxi(form, enableOperate, arrArrylist) {
      fieldlist(form).then(response => {
        if (response.data.field != null && response.data.field != "" && response.data.field != undefined) {
          if (enableOperate == 'data') {
            var arr = response.data.field.split(',')
            const result = arr.reduce((acc, item) => {
              const [key, value] = item.trim().split("$");
              acc[key] = value;
              return acc;
            }, {});
            console.log(arr, result)
            for (let i = 0; i < arr.length; i++) {
              if (arrArrylist.filter((item) => item.fieldName == Object.keys(result)[i]).length != 0) {
                const data = arrArrylist.filter((item) => item.fieldName == Object.keys(result)[i])
                data[0].isOrder = Object.values(result)[i]
                this.myDataChecked = this.myDataChecked.concat(data)
              }
            }
          } else {
            var arr = response.data.field.split(',')
            for (let i = 0; i < arr.length; i++) {
              const data = arrArrylist.filter((item) => item.fieldName === arr[i])
              this.myDataChecked = this.myDataChecked.concat(data)
            }
          }
        }
        this.ApplyDetailData = arrArrylist
      })
    },
    // 获取应用定义表格数据
    getApplyList() {
      this.loading = true;
      this.queryParam.categoryId = this.queryParams.id
      console.log(this.queryParam, "----------------")
      getApply(this.queryParam).then(response => {
        this.applyList = response.rows;
        this.applyTotal = response.total;
        this.loading = false;
      });
    },
    // 新增模块
    submitApply() {
      this.applyOpen = false;
      this.getApplyList();
    },
    closeApply() {
      this.applyDetailOpen = false
      this.IsJuanDetail = false
      this.IsJianDetail = false
      this.IsDzwjDetail = false
      this.IsXmDetail = false
      this.enableOperate = ''
      this.myDataChecked = []
      this.ApplyDetailData = []
    },
    // 点击项目明细按钮
    XmDetail() {
      this.myDataChecked = []
      this.applyDetailOpen = true
      this.IsXmDetail = false
      this.IsJuanDetail = true
      this.IsJianDetail = true
      this.IsDzwjDetail = true
      this.form = {
        categoryId: this.cateMdataQueryParams.categoryId,
        groupId: this.cateMdataQueryParams.groupId,
        type: 3,
        pageNum: 1,
        pageSize: 200,
      }
      if (this.enableOperate == 'show') {
        this.form.isHidden = 0;
      }
      if (this.enableOperate == 'add') {
        this.form.isInput = 1;
      }
      if (this.enableOperate == 'update') {
        this.form.isUpdate = 1;
      }
      if (this.enableOperate == 'export') {
        this.form.isExport = 1;
      }
      if (this.enableOperate == 'query') {
        this.form.isQuery = 10;
      }
      if (this.enableOperate == 'data') {
        this.form.isHidden = 0;
      }
      var arrArrylist=[];
      cateMdataList(this.form).then(response => {
        arrArrylist = response.rows.map((item, index) => {
          return {
            fieldCaption: item.fieldCaption,
            fieldName: item.fieldName,
            isOrder: 'asc',
            key: index
          }
        })
        // 各个展示的按钮
        var field = ""
        if (this.enableOperate == 'show') {
          field = "xiangmulistfield"
        } else if (this.enableOperate == 'add') {
          field = "xiangmuaddfield"
        } else if (this.enableOperate == 'update') {
          field = "xiangmuupdatefield"
        } else if (this.enableOperate == 'export') {
          field = "xiangmuexportfield"
        } else if (this.enableOperate == 'query') {
          field = "xiangmuquery"
        } else if (this.enableOperate == 'data') {
          field = "xiangmuorder"
        }
        this.form = {
          menuId: this.menuID,
          categoryId: this.cateMdataQueryParams.categoryId,
          field: field
        }
        this.getApplyXinxi(this.form, this.enableOperate,arrArrylist)
      })
    },
    // 点击卷明细按钮
    JuanDetail() {
      this.myDataChecked = []
      this.applyDetailOpen = true
      this.IsJuanDetail = false
      this.form = {
        categoryId: this.cateMdataQueryParams.categoryId,
        groupId: this.cateMdataQueryParams.groupId,
        type: 1,
        pageNum: 1,
        pageSize: 200,
      }
      if (this.enableOperate == 'show') {
        this.form.isHidden = 0;
      }
      if (this.enableOperate == 'add') {
        this.form.isInput = 1;
      }
      if (this.enableOperate == 'update') {
        this.form.isUpdate = 1;
      }
      if (this.enableOperate == 'export') {
        this.form.isExport = 1;
      }
      if (this.enableOperate == 'query') {
        this.form.isQuery = 10;
      }
      if (this.enableOperate == 'data') {
        this.form.isHidden = 0;
      }
      var arrArrylist=[];
      cateMdataList(this.form).then(response => {
        arrArrylist = response.rows.map((item, index) => {
          return {
            fieldCaption: item.fieldCaption,
            fieldName: item.fieldName,
            isOrder: 'asc',
            key: index
          }
        })
        // 各个展示的按钮
        var field = ""
        if (this.enableOperate == 'show') {
          field = "juanlistfield"
        } else if (this.enableOperate == 'add') {
          field = "juanaddfield"
        } else if (this.enableOperate == 'update') {
          field = "juanupdatefield"
        } else if (this.enableOperate == 'export') {
          field = "juanexportfield"
        } else if (this.enableOperate == 'query') {
          field = "juanquery"
        } else if (this.enableOperate == 'data') {
          field = "juanorder"
        }
        this.form = {
          menuId: this.menuID,
          categoryId: this.cateMdataQueryParams.categoryId,
          field: field
        }
        this.getApplyXinxi(this.form, this.enableOperate,arrArrylist)
      })
      if (this.queryParams.type == 1) { //卷
        this.IsJianDetail = true
        this.IsDzwjDetail = true
      } else if (this.queryParams.type == 3) { //项目
        this.IsJianDetail = true
        this.IsDzwjDetail = true
        this.IsXmDetail = true
      }
    },
    // 点击件明细
    JianDetail() {
      this.myDataChecked = []
      this.applyDetailOpen = true
      this.IsJianDetail = false
      this.form = {
        categoryId: this.cateMdataQueryParams.categoryId,
        groupId: this.cateMdataQueryParams.groupId,
        type: 0,
        pageNum: 1,
        pageSize: 200,
      }
      if (this.enableOperate == 'show') {
        this.form.isHidden = 0;
      }
      if (this.enableOperate == 'add') {
        this.form.isInput = 1;
      }
      if (this.enableOperate == 'update') {
        this.form.isUpdate = 1;
      }
      if (this.enableOperate == 'export') {
        this.form.isExport = 1;
      }
      if (this.enableOperate == 'query') {
        this.form.isQuery = 10;
      }
      if (this.enableOperate == 'data') {
        this.form.isHidden = 0;
      }
      var arrArrylist=[];
      cateMdataList(this.form).then(response => {
        arrArrylist = response.rows.map((item, index) => {
          return {
            fieldCaption: item.fieldCaption,
            fieldName: item.fieldName,
            isOrder: 'asc',
            key: index
          }
        })
        // 各个展示的按钮
        var field = ""
        if (this.enableOperate == 'show') {
          field = "jianlistfield"
        } else if (this.enableOperate == 'add') {
          field = "jianaddfield"
        } else if (this.enableOperate == 'update') {
          field = "jianupdatefield"
        } else if (this.enableOperate == 'export') {
          field = "jianexportfield"
        } else if (this.enableOperate == 'query') {
          field = "jianquery"
        } else if (this.enableOperate == 'data') {
          field = "jianorder"
        }
        this.form = {
          menuId: this.menuID,
          categoryId: this.cateMdataQueryParams.categoryId,
          field: field
        }
        this.getApplyXinxi(this.form, this.enableOperate,arrArrylist)
      })
      if (this.queryParams.type == 1) { // 卷
        this.IsJuanDetail = true
        this.IsDzwjDetail = true
      } else if (this.queryParams.type == 3) { //项目
        this.IsJuanDetail = true
        this.IsDzwjDetail = true
        this.IsXmDetail = true
      } else if (this.queryParams.type == 0) { //件
        this.IsDzwjDetail = true
      }
    },
    // 点击电子文件明细
    DzwjDetail() {
      this.myDataChecked = []
      this.applyDetailOpen = true
      this.IsDzwjDetail = false
      this.form = {
        categoryId: this.cateMdataQueryParams.categoryId,
        groupId: this.cateMdataQueryParams.groupId,
        type: 2,
        pageNum: 1,
        pageSize: 200,
      }
      if (this.enableOperate == 'show') {
        this.form.isHidden = 0;
      }
      if (this.enableOperate == 'add') {
        this.form.isInput = 1;
      }
      if (this.enableOperate == 'update') {
        this.form.isUpdate = 1;
      }
      if (this.enableOperate == 'export') {
        this.form.isExport = 1;
      }
      if (this.enableOperate == 'query') {
        this.form.isQuery = 10;
      }
      if (this.enableOperate == 'data') {
        this.form.isHidden = 0;
      }
      var arrArrylist=[];
      cateMdataList(this.form).then(response => {
        console.log(response,"---------------")
        arrArrylist = response.rows.map((item, index) => {
          return {
            fieldCaption: item.fieldCaption,
            fieldName: item.fieldName,
            isOrder: 'asc',
            key: index
          }
        })
        // 各个展示的按钮
        var field = ""
        if (this.enableOperate == 'show') {
          field = "efilelistfield"
        } else if (this.enableOperate == 'add') {
          field = "efileaddfield"
        } else if (this.enableOperate == 'update') {
          field = "efileupdatefield"
        } else if (this.enableOperate == 'export') {
          field = "efileexportfield"
        } else if (this.enableOperate == 'query') {
          field = "efilequery"
        } else if (this.enableOperate == 'data') {
          field = "efileorder"
        }
        this.form = {
          menuId: this.menuID,
          categoryId: this.cateMdataQueryParams.categoryId,
          field: field
        }
        this.getApplyXinxi(this.form, this.enableOperate,arrArrylist)
      })
      if (this.queryParams.type == 1) { // 卷
        this.IsJuanDetail = true
        this.IsJianDetail = true
      } else if (this.queryParams.type == 3) { //项目
        this.IsJuanDetail = true
        this.IsJianDetail = true
        this.IsXmDetail = true
      } else if (this.queryParams.type == 0) { //件
        this.IsJianDetail = true
      }
    },
    // 保存应用明细
    submitApplyDetail(value, isOrder, biaoshi) {
      this.ProcessData(value, isOrder, this.enableOperate, this.menuID)
      // console.log('form表单:',this.form,'biaoshi:',biaoshi)
      if (biaoshi == false) {
        addApplyDetail(this.form).then(response => {
          // this.applyDetailOpen = false;
          // this.getApplyList();
          // this.enableOperate = ''
        })
      } else {
        addApplyDetail(this.form).then(response => {
          this.applyDetailOpen = false;
          this.getApplyList();
          this.enableOperate = ''
          this.myDataChecked = []
          this.ApplyDetailData = []
        })
      }
    },
    // 对字段进行处理
    ProcessData(value, isOrder, enableOperate, menuID) {
      // console.log('操作',enableOperate)
      // console.log(value,'-----------',isOrder)
      // console.log('件:',this.IsJianDetail,',卷:',this.IsJuanDetail,',项目:',this.IsXmDetail,',电子文件:',this.IsDzwjDetail)
      this.form = {
        menuId: menuID,
        categoryId: this.queryParams.id
      }
      // 列表展示
      if (this.enableOperate == 'show') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.jianlistfield = arr.map(field => field.replace(/'/g, "")).toString() // 件展示字段
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.efilelistfield = arr.map(field => field.replace(/'/g, "")).toString() // 电子文件展示字段
        } else if (this.IsJuanDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.juanlistfield = arr.map(field => field.replace(/'/g, "")).toString() // 卷展示字段
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.xiangmulistfield = arr.map(field => field.replace(/'/g, "")).toString() // 项目字段
        }
      }
      // 添加展示
      else if (this.enableOperate == 'add') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.jianaddfield = arr.map(field => field.replace(/'/g, "")).toString() // 件添加字段
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.efileaddfield = arr.map(field => field.replace(/'/g, "")).toString()  // 电子文件添加字段
        } else if (this.IsJuanDetail == false) {
          var arr = [] // 卷字段
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.juanaddfield = arr.map(field => field.replace(/'/g, "")).toString()  // 卷添加字段
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.xiangmuaddfield = arr.map(field => field.replace(/'/g, "")).toString() // 项目添加字段
        }
      }
      // 修改展示
      else if (this.enableOperate == 'update') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.jianupdatefield = arr.map(field => field.replace(/'/g, "")).toString() // 件修改字段
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.efileupdatefield = arr.map(field => field.replace(/'/g, "")).toString()  // 电子文件修改字段
        } else if (this.IsJuanDetail == false) {
          var arr = [] // 卷字段
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.juanupdatefield = arr.map(field => field.replace(/'/g, "")).toString()  // 卷修改字段
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.xiangmuupdatefield = arr.map(field => field.replace(/'/g, "")).toString() // 项目修改字段
        }
      }
      // 导出展示
      else if (this.enableOperate == 'export') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.jianexportfield = arr.map(field => field.replace(/'/g, "")).toString() // 件导出字段
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.efileexportfield = arr.map(field => field.replace(/'/g, "")).toString()  // 电子文件导出字段
        } else if (this.IsJuanDetail == false) {
          var arr = [] // 卷字段
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.juanexportfield = arr.map(field => field.replace(/'/g, "")).toString()  // 卷导出字段
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.xiangmuexportfield = arr.map(field => field.replace(/'/g, "")).toString() // 项目导出字段
        }
      }
      // 查询展示
      else if (this.enableOperate == 'query') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.jianquery = arr.map(field => field.replace(/'/g, "")).toString() // 件查询字段
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.efilequery = arr.map(field => field.replace(/'/g, "")).toString()  // 电子文件查询字段
        } else if (this.IsJuanDetail == false) {
          var arr = [] // 卷字段
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.juanquery = arr.map(field => field.replace(/'/g, "")).toString()  // 卷查询字段
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code
                arr.push(str)
              }
            }
          }
          this.form.xiangmuquery = arr.map(field => field.replace(/'/g, "")).toString() // 项目查询字段
        }
      }
      // 数据展示
      else if (this.enableOperate == 'data') {
        if (this.IsJianDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code + "$" + isOrder[i].isOrder
                arr.push(str)
              }
            }
          }
          this.form.jianorder = arr.toString() // 件数据排序
        } else if (this.IsDzwjDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code + "$" + isOrder[i].isOrder
                arr.push(str)
              }
            }
          }
          this.form.efileorder = arr.toString() // 电子文件数据排序
        } else if (this.IsJuanDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code + "$" + isOrder[i].isOrder
                arr.push(str)
              }
            }
          }
          this.form.juanorder = arr.toString()  // 卷数据排序
        } else if (this.IsXmDetail == false) {
          var arr = []
          for (var j = 0; j < value.length; j++) {
            for (var i = 0; i < isOrder.length; i++) {
              if (isOrder[i].key == value[j]) {
                const str = isOrder[i].code + "$" + isOrder[i].isOrder
                arr.push(str)
              }
            }
          }
          this.form.xiangmuorder = arr.toString() // 项目数据排序
        }
      }
    },



    /****start   元数据信息明细 */

    //元数据信息明细查询
    getCateMdataList() {
      this.cateMdataLoading = true;
      cateMdataList(this.cateMdataQueryParams).then(response => {
        console.log('response.rows :>> ', response.rows);
        this.cateMdataList = response.rows;
        this.cateMdataTotal = response.total;
        this.cateMdataLoading = false;
      }
      ).catch(res => {
        this.cateMdataLoading = false;
      });
    },

    // 元数据信息明细列表多选框选中数据
    cateMdatahandleSelectionChange(ids, selection) {
      this.cateMdataIds = ids;
      this.cateMdataLabel = selection.map(item => item.fieldCaption);
    },

    toUpperCase() {
      this.cateMdataQueryParams.fieldName = this.cateMdataQueryParams.fieldName.toUpperCase()
    },

    /** 元数据信息明细搜索按钮操作 */
    cateMdataHandleQuery() {
      this.cateMdataQueryParams.pageNum = 1;
      this.getCateMdataList();
    },
    //元数据信息明细类型触发事件
    cateMdataSelectTap(data) {
      console.log(data)
      this.cateMdataQueryParams.type = data;
      this.cateMdataQueryParams.pageNum = 1;
      this.cateMdataQueryParams.PageSize = 10;
      console.log(this.cateMdataQueryParams, "++++++++++++++")
      this.getCateMdataList();
    },

    //元数据信息明细添加
    cateMdatahandleAdd() {
      var that = this;
      if (this.cateMdataQueryParams.groupId == undefined) {
        this.$modal.msgError("请选择元数据方案");
        return;
      }
      that.cateMdataOpen = true;
      this.addParams = {
        cateIsType: "0",
        queryAddParams: this.cateMdataQueryParams
      }

    },
    //元数据信息明细添加页面关闭
    closeMdataDelDialog() {
      var that = this;
      that.cateMdataOpen = false;

      this.getCateMdataList();
    },
    //关闭设置规则
    closeSetRuleDialog() {
      this.setRuleOpen = false;
    },
    //关闭分类方法
    closeClassifyDialog() {
      this.classifyOpen = false;
    },

    //删除元数据信息明细列表数据
    cateMdatahandleDelete(row) {
      const ids = row.id || this.cateMdataIds;
      const label = row.fieldCaption || this.cateMdataLabel
      console.log(ids)
      if (ids.length !== 0) {
        this.$modal.confirm('是否确认删除显示名称为"' + label + '"的数据项？').then(function () { }).then(() => {
          delcateMdata({
            categoryId: this.cateMdataQueryParams.categoryId,
            type: this.cateMdataQueryParams.type,
          }, ids.toString());
          this.getCateMdataList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => { });
      } else {
        this.$modal.msgError("请选择要删除的数据");
      }
    },

    //修改元数据明细批量操作
    chanageVatchOperationTap(data) {
      this.cateMdataList = data;
    },

    //设置规则弹窗
    setRuleTap(row) {
      this.setRuleOpen = true
      this.addParams = {
        cateIsType: "0",
        queryAddParams: this.cateMdataQueryParams,
        row: row
      }
    },
    //分类方法
    classifyTap() {
      this.classifyOpen = true
      this.addParams = {
        cateIsType: "0",
        queryAddParams: this.cateMdataQueryParams
      }
    },

    //添加修改制度树
    treeZdAdd() {
      if (this.parentId == undefined || this.parentId == "") {
        this.$modal.msgWarning('请选择要添加的父节点')
        return false
      }
      this.zdTreeDeitOpen = true
      this.addParams = {
        cateIsType: "0",
        parentId: this.parentId,
        queryAddParams: this.cateMdataQueryParams
      }
    },
    //制度树关闭方法
    closezdTreeDeitDialog() {
      this.zdTreeDeitOpen = false
    },

    //制度树添加修改成功
    submitzdTrreForm() {
      this.zdTreeDeitOpen = false;
      this.parentId = undefined;
      this.gdfwandbgqxTreePost();
    },

    //制度树修改弹窗
    treeZdUpdate() {
      if (this.parentId == undefined || this.parentId == "") {
        this.$modal.msgWarning('请选择要修改的节点')
        return false
      }
      if (this.parentId == 0) {
        this.$modal.msgWarning('请选择除根节点以外的节点进行修改')
        return false
      }
      this.zdTreeDeitOpen = true
      this.addParams = {
        cateIsType: "0",
        deitInfo: this.deitInfo,
        queryAddParams: this.cateMdataQueryParams
      }
    },
    //删除制度树
    treeZdDelete() {
      var that = this;
      if (this.deitInfo.id != undefined) {
        getzd(this.deitInfo.id).then(res => {
          if (res.code == "200") {
            this.$modal.confirm('是否确认删除显示名称为"' + this.deitInfo.label + '"的数据项？').then(function () {
              gdfwandbgqxEditzd({
                id: res.data.id,
                name: res.data.name,
                bgqx: res.data.bgqx,
                remark: res.data.remark,
                orderNo: res.data.orderNo,
                isDel: 1
              }).then(res1 => {
                if (res1.code == "200") {
                  that.$modal.msgSuccess("删除成功")
                  that.gdfwandbgqxTreePost();
                } else {
                  that.$modal.msgError("删除失败");
                }
              })
            }).catch(res => {
              console.log("取消")
            })
          }
        }).catch(res => {

        })
      } else {
        that.$modal.msgError("请选择要删除的数据");
      }


    },
    //制度树列表
    gdfwandbgqxTreePost() {
      var that = this;
      gdfwandbgqxTree(this.cateMdataQueryParams.categoryId).then(res => {
        if (res.code == "200") {
          this.gdfwandOptions = res.data;
        }

      })
    },

    //点击制度树
    gdfwandNodeClick(data) {
      this.parentId = data.id;
      this.deitInfo = data;
      this.gettableListPost();
    },
    //获取制度树表格
    gettableListPost() {
      gettable(this.parentId, this.cateMdataQueryParams.categoryId).then(res => {
        if (res.code == "200") {
          this.tableZdData = res.rows;
        }

      }).catch(res => {

      })
    }
  }
}
</script>
<style lang="scss" scoped>
.first {
  li {
    line-height: 50px;
    height: 50px;
    display: flex;
    // font-size: 14px;
    color: #606266;
  }

  li>label {
    width: 100px;
    text-align: right;
    margin-right: 10px;
  }
}

.el-dropdown-menu__item label {
  width: 100px !important;
  display: inline-block;
}

.el-select {
  width: 100%;

}

::v-deep.el-input input {
  text-align: center;
}





.select-model {
  width: 19.1%;
}

.fuhao-model {
  //width: 5.06%;
  width: 10%;
}

.transfer-box {
  display: flex;

  .transfer-box-left {
    border: 2px solid black;
    border-radius: 10px;
    width: 40%;
    height: 240px;
    overflow-y: scroll;
    margin-left: 20px;

    .box-ul {
      list-style: none;
      line-height: 1.5em;
    }
  }

  .transfer-box-center {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .transfer-box-right {
    border: 2px solid black;
    border-radius: 10px;
    width: 40%;
    height: 240px;
    overflow-y: scroll;
    margin-left: 20px;

    .box-ul {
      list-style: none;
      line-height: 1.5em;
    }
  }

  .box-title-icon {
    color: #f0463f;
  }
}

.el-form-item {
  //margin-bottom: 12px;
}

.el-table--medium .el-table__cell {
  padding: 7px 0 !important;
}
</style>
